package com.enjoyor.soa.traffic.server.tsms.dubbo.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.tsms.ExecuteTaskDispatchDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tsms.IDubboExecuteTaskDispatchService;
import com.enjoyor.soa.traffic.core.tsms.domain.ExecuteTaskDispatch;
import com.enjoyor.soa.traffic.core.tsms.service.IExecuteTaskDispatchService;
import com.enjoyor.soa.traffic.frame.support.util.DomainUtil;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@SuppressWarnings("rawtypes")
@Service(version = "1.0.0", timeout = 4000)
public class DubboExecuteTaskDispatchService implements IDubboExecuteTaskDispatchService{

	@Autowired
	private IExecuteTaskDispatchService iExecuteTaskDispatchService;
	
	@Override
	public ResultPojo getExecuteTaskDispatchPage(Page page,String dispatchId, String executeTaskId) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo(iExecuteTaskDispatchService.getExecuteTaskDispatchPage(page,dispatchId, executeTaskId));
		return resultPojo;
	}

	@Override
	public ResultPojo getExecuteTaskDispatchList(String dispatchId, String executeTaskId, String postId,
			String policeId, String policeName) {
		// TODO Auto-generated method stub
		List<ExecuteTaskDispatch> list = iExecuteTaskDispatchService.getExecuteTaskDispatchList(dispatchId,
				executeTaskId, postId, policeId, policeName);
		ResultPojo resultPojo = new ResultPojo(ReflectHelper.listToList(list, ExecuteTaskDispatchDto.class));
		return resultPojo;
	}

	@Override
	public ResultPojo addExecuteTaskDispatch(ExecuteTaskDispatchDto executeTaskDispatchDto, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		iExecuteTaskDispatchService.addExecuteTaskDispatch(
				ReflectHelper.beanToBean(executeTaskDispatchDto, ExecuteTaskDispatch.class), personName);
		return resultPojo;
	}

	@Override
	public ResultPojo editExecuteTaskDispatch(ExecuteTaskDispatchDto executeTaskDispatchDto, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		iExecuteTaskDispatchService.editExecuteTaskDispatch(ReflectHelper.beanToBean(executeTaskDispatchDto, ExecuteTaskDispatch.class),personName);
		return resultPojo;
	}

	@Override
	public ResultPojo deleteExecuteTaskDispatch(String dispatchId, String personName) {
		// TODO Auto-generated method stub
		iExecuteTaskDispatchService.deleteExecuteTaskDispatch(dispatchId, personName);
		return new ResultPojo();
	}

	@Override
	public ResultPojo assignExecuteTaskDispatch(List<ExecuteTaskDispatchDto> list, String executeTaskId,
			String personName) {
		// TODO Auto-generated method stub
		List<ExecuteTaskDispatch> listAssPolice = DomainUtil.merge2ListJson(list, ExecuteTaskDispatch.class);
		String result = iExecuteTaskDispatchService.assignExecuteTaskDispatch(listAssPolice, executeTaskId, personName);
		return new ResultPojo(result);
	}

}
